<!---->
<template>
    <div class="page_memberOptionmemberInfo">
        <common-header :title="'个人基本信息编辑'">
            <span slot="overwrite-left"></span>
        </common-header>
        <div class="btn-save" @click="savememberInfo">保存</div>
        <div class="pages-main" style="height: calc( 100vh - 45px)">
            <div class="item-info">
                <div class="item-item">
                    <x-input title="户籍派出所" v-model="memberInfo.policename"
                             placeholder="请输入户籍派出所">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="曾用名" v-model="memberInfo.formername"
                             placeholder="请输入曾用名">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="手机号" v-model="memberInfo.contractphone"
                             placeholder="请输入手机号">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="固话号码" v-model="memberInfo.telephone"
                             placeholder="请输入固话号码">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="电子邮箱" v-model="memberInfo.email"
                             placeholder="请输入电子邮箱">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="职业" v-model="memberInfo.job"
                             placeholder="请输入职业">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="工作单位" v-model="memberInfo.companyname"
                             placeholder="请输入工作单位">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="就读学校" v-model="memberInfo.school"
                             placeholder="请输入就读学校">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="身高（cm）" type="number" v-model="memberInfo.high"
                             placeholder="请输入身高">
                    </x-input>
                </div>
                <div class="item-item  every-block-padding item-inline">
                    <span class="item-itemLabel">血型</span>
                    <select class="translateBlock" v-model="memberInfo.bloodgroup"
                            style="text-align-last: right;;width: 8rem;font-size:0.38rem;">
                        <option :value="'A型'">A型</option>
                        <option :value="'B型'">B型</option>
                        <option :value="'O型'">O型</option>
                        <option :value="'AB型'">AB型</option>
                        <option :value="'其他'">其他</option>
                    </select>
                </div>
                <div class="item-item">
                    <x-input title="宗教信仰" v-model="memberInfo.religiousbelief"
                             placeholder="请输入宗教信仰">
                    </x-input>
                </div>
                <div class="item-item">
                    <x-input title="居住地址" v-model="memberInfo.address"
                             placeholder="请输入居住地址">
                    </x-input>
                </div>
            </div>

        </div>
    </div>
</template>

<script>
    import {XInput, Tab, TabItem, Datetime} from 'vux'
    import resident from '../../services/resident'
    import {checkPhone, checkEmail, checkPhonenumber, checkHight} from '../../utils/validate'

    export default {
        name: "memberOptionmemberInfo",
        components: {
            XInput,
            Tab,
            TabItem,
            Datetime
        },
        data() {
            return {
                familyid: this.$route.query.familyid,
                memberInfo: {
                    id: this.$route.query.id,
                    policename: this.$route.query.policename ? this.$route.query.policename : '',
                    formername: this.$route.query.formername ? this.$route.query.formername : '',
                    companyname: this.$route.query.companyname ? this.$route.query.companyname : '',
                    high: this.$route.query.high ? this.$route.query.high : '',
                    contractphone: this.$route.query.contractphone ? this.$route.query.contractphone : '',
                    telephone: this.$route.query.telephone ? this.$route.query.telephone : '',
                    email: this.$route.query.email ? this.$route.query.email : '',
                    job: this.$route.query.job ? this.$route.query.job : '',
                    school: this.$route.query.school ? this.$route.query.school : '',
                    bloodgroup: this.$route.query.bloodgroup ? this.$route.query.bloodgroup : 'A型',
                    religiousbelief: this.$route.query.religiousbelief ? this.$route.query.religiousbelief : '',
                    address: this.$route.query.address ? this.$route.query.address : '',
                },
            }
        },

        created() {

        },
        watch: {},
        methods: {
            // updatePopulationOthermemberInfo
            // 保存个人基本信息
            savememberInfo() {
                if (this.memberInfo.contractphone) {
                    if (!checkPhone(this.memberInfo.contractphone)) {
                        return;
                    }
                }
                if (this.memberInfo.telephone) {
                    if (!checkPhonenumber(this.memberInfo.telephone, '请输入正确的固话号码')) {
                        return;
                    }
                }
                if (this.memberInfo.email) {
                    if (!checkEmail(this.memberInfo.email)) {
                        return;
                    }
                }

                if (this.memberInfo.high) {
                    if (!checkHight(this.memberInfo.high)) {
                        return;
                    }
                }

                let _param = this.$tools.invokeUAF('resident/updatePopulationOtherInfo', this.memberInfo)
                resident.updatePopulationOtherInfo(_param).then(res => {
                    let data = res.data.data;
                    if (res.data.code === '0') {
                        this.$tools.goPage_query('addmember', {
                            familyid: this.familyid,
                            populationId: this.memberInfo.id,
                        })
                    }

                })
            },
        },
    };
</script>

<style lang="less" rel="stylesheet/less" type="text/css">
    .page_memberOptionmemberInfo {

    }
</style>
